<%@ page import="com.broadvision.emarketing.criteriabuilder.*"%>
<%@ page import="java.util.List"%>
<%@ page import="org.apache.struts.taglib.TagUtils"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<%@include file="/mt/common/pickerPopupHelper.jsp" %>

<SCRIPT language='Javascript'>

function cancelAction(){
  	form = document.forms["emSegmentConditionForm"];
	form.action="<html:rewrite page="/em/cb/displayCriteriaBuilder.do"/>";
	form.submit();
}

function validate_fields(form) {

    if( form.segmentName.value == "") {
      alert(" <bean:message bundle="em" key="em.cb.segmentCondition.alert.selectsegment" /> ");
      return false;
    }

    return true;
}


function onSelectSegment( selectedOids, selectedNames) {
  theForm = document.emSegmentConditionForm;
  theForm.segmentName.value = selectedNames.toString();
  theForm.segmentOid.value = parseInt(selectedOids.toString());
}

</SCRIPT>

<%String actionStr = ""; %>
<logic:equal name="emSegmentConditionForm" property="userAction" value="edit" >
  <% TagUtils util = TagUtils.getInstance();
     actionStr = util.message(pageContext, "em", request.getLocale().toString(),"em.label.edit");
   %>
</logic:equal>
<logic:equal name="emSegmentConditionForm" property="userAction" value="create" >
  <% TagUtils util = TagUtils.getInstance();
	actionStr = util.message(pageContext, "em", request.getLocale().toString(),"em.label.create");
   %>
</logic:equal>

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="zoneFive">
	<tr>

	<c:set var="title">
	<bean:message bundle="em" key="em.cb.segmentCondition.title" />
	</c:set>

		<td valign="top" width="100%">

		<div class="pageTitle">

		<bean-el:message bundle="em" key="em.title.order" arg0="<%=actionStr%>" arg1="${title}" /><br>
		</div>

		<div class="pageInstructions">
				<bean:message bundle="em"
						key="em.cb.segmentCondition.pageInstructions" /></br>
		</div>

          <div class="pageSubTitle">
			<bean-el:message bundle="em" key="em.title.order" arg0="<%=actionStr%>" arg1="${title}" /><br>
		</div>


		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="labelForm">
		<html:form onsubmit="return validate_fields(this);" action="/em/cb/updateSegmentCondition.do">
			<html:hidden name="emSegmentConditionForm" property="segmentOid" />
			<html:hidden name="emSegmentConditionForm" property="key" />
			<html:hidden name="emSegmentConditionForm" property="userAction" />
			<tr>
				<td><html:errors /></td>
			</tr>
			<tr>
				<td valign="top" wrap class="label" width="20%">
					<bean:message bundle="em" key="emarketing.criteriaBuilder.genericConditionList.label.theVisitor" />
				</td>

				<td valign="top" wrap class="labelField" width="80%">
					<bean:define id="operators" name="emSegmentConditionForm" property="operatorList" type="java.util.Collection" />
					<html:select name="emSegmentConditionForm" property="operator">
						<html:options collection="operators" property="value" labelProperty="label" />
					</html:select>
					<html:text name="emSegmentConditionForm" property="segmentName" readonly="true" />
 				        <input type="button" name="browseSegment"
						value="<bean:message bundle="em" key="em.cb.segmentCondition.choosesegment"/>"
						class="inputButton" onclick="doPickerPopupAction('<html:rewrite page="/mt/pickerPopup.do"/>', 'onSelectSegment', 56, null, null,null, true, false, true);" />
				</td>
			</tr>
		</table>

		<div class="pageButtonWrap" align="right">
			<input type="button" name="Reset" value="<bean:message bundle="em" key="button.cancel"/>"
						class="inputButton" onclick="javascript:cancelAction()" />
			<input type="submit" name="Continue" value="<bean:message bundle="em" key="button.done"/>" class="inputButton" />
		</div>

		</html:form>
		</td>
	</tr>
</table>
	<!--end zone 5 content area here-->


